//
//  FXVisitorTableViewController.swift
//  微博(Swift)
//
//  Created by V on 15/12/28.
//  Copyright © 2015年 V. All rights reserved.
//

import UIKit

class FXVisitorTableViewController: UITableViewController {
    // 是否登录：1. 本地是否有用户信息，2.是否有 accessToken，3. accessToken 没有过期
    var userLogin: Bool = FXUserAccountViewModel.sharedViewModel.userLogin

    override func loadView() {
        userLogin == true ? super.loadView() : setupUI()
    }
    
    

    override func viewDidLoad() {
        super.viewDidLoad()
//        visitorView.delegate = self
        
    }
    
    
    lazy var visitorView: FXVisitorView = FXVisitorView()
    
    private func setupUI(){
        view = visitorView
        visitorView.registerBtn.addTarget(self, action: "registerBtnClick", forControlEvents: .TouchUpInside)
        visitorView.loginBtn.addTarget(self, action: "loginBtnClick", forControlEvents: .TouchUpInside)

        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "registerBtnClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "loginBtnClick")
    }
    
    
    
//    // MARK: - 实现代理的方法
//    func registerBtnClick() {
//        print("注册")
//    }
//    func loginBtnClick() {
//        print("登录")
//    }
    
    // MARK: - 点击btn
     @objc private func registerBtnClick(){
        print("注册")
        let vc = FXNavigationController(rootViewController: FXOAuthViewController())
        presentViewController(vc, animated: true, completion: nil)
    }
    @objc private func loginBtnClick(){
        print("登录")
        let vc = FXNavigationController(rootViewController: FXOAuthViewController())
        presentViewController(vc, animated: true, completion: nil)
    }
    
    
    
    
    

    
}
